/********************************************************************************/
/** dmb This was done so deletes can perform correctly from MyImages Gridview **/
/******************************************************************************/

USE Image
GO

ALTER TABLE [dbo].[UserImageRating] DROP CONSTRAINT FK_UserImageRating2

ALTER TABLE [dbo].[UserImageRating]
ADD CONSTRAINT [FK_UserImageRating2]
    FOREIGN KEY ([imageid])
    REFERENCES [dbo].[Image]
        ([imageid])
    ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE [dbo].[UserImage] DROP CONSTRAINT FK_UserImage2

	-- Creating foreign key on [imageid] in table 'UserImage'
ALTER TABLE [dbo].[UserImage]

ADD CONSTRAINT [FK_Us0erImage2]
    FOREIGN KEY ([imageid])
    REFERENCES [dbo].[Image]
        ([imageid])
    ON DELETE CASCADE ON UPDATE NO ACTION;


	ALTER TABLE [dbo].[ImageCategory] DROP CONSTRAINT FK_ImageCategory1

	ALTER TABLE [dbo].[ImageCategory]
ADD CONSTRAINT [FK_ImageCategory1]
    FOREIGN KEY ([imageid])
    REFERENCES [dbo].[Image]
        ([imageid])
    ON DELETE CASCADE ON UPDATE NO ACTION;